<?php

namespace App\Models;

class CompanyInfos extends Base
{
    protected $table = 'company_infos';

    protected $fillable = [
        'id','code','name','pid','type','status','created_at','updated_at'
    ];

    /**
     * 获取数据
     * @return mixed
     */
    protected function getList($params, $fields = ['*']){
        $lists = $this->select($fields)->where($params)->get();
        return $lists;
    }

    /**
     * 获取级联列表
     * @return mixed
     */
    protected function getCascaderList($params=[]){
        $lists = $this->where($params)->get(['id as value','name as label','pid'])->toArray();
        return $this->listToTree($lists, 'value');
    }

}
